<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/10/12
 * Time: 15:28
 */
namespace app\index\model;
use think\Model;

class User extends Model
{
//    protected  $table = 'think_user';

    //开启自动写入时间戳
    protected $autoWriteTimestamp = true;

    //定义自动完成属性
    protected $insert = ['status'=>1];

    // 定义关联方法
    public function profile(){
        //用户HAS ONE档案关联
        return $this->hasOne('Profile');
    }

    // 定义关联方法
    public function books(){
        //用户HAS ONE档案关联
        return $this->hasMany('Book');
    }

    protected function getStatusAttr($value){
        $status = ['1'=>'启动','0'=>'禁止'];
        return $status[$value];
    }



}